package cz.najman.emdroid.mappings;

import java.util.HashMap;
import java.util.Map;

import cz.najman.emdroid.provider.EMDroidDataProvider;
import cz.najman.emdroid.provider.Flags;
import android.net.Uri;
import android.provider.BaseColumns;

public class User extends Mappings implements BaseColumns, Flags {

	/**
	 * Uri string representing the user resource
	 */
	public static final String URI_STRING_USERS = "content://" + EMDroidDataProvider.AUTHORITY + "/users";	
	
	public static final String URI_STRING_USERS_BY_EMAIL = "content://" + EMDroidDataProvider.AUTHORITY + "/users/byEmail";
	
	public static final String URI_STRING_USERS_FOR_EVENT = "content://" + EMDroidDataProvider.AUTHORITY + "/users/forEvent";
	
	public static final String URI_STRING_USERS_FOR_INSTITUTION = "content://" + EMDroidDataProvider.AUTHORITY + "/users/forInstitution";
	
	public static final Uri CONTENT_URI_USERS = Uri.parse(URI_STRING_USERS);
	
	public static final Uri CONTENT_URI_USERS_BY_EMAIL = Uri.parse(URI_STRING_USERS_BY_EMAIL);
	
	public static final Uri CONTENT_URI_USERS_FOR_EVENT = Uri.parse(URI_STRING_USERS_FOR_EVENT);
	
	public static final Uri CONTENT_URI_USERS_FOR_INSTITUTION = Uri.parse(URI_STRING_USERS_FOR_INSTITUTION);
	
	/**
	 * Content type dir
	 */
	public static final String CONTENT_TYPE_DIR = "vnd.android.cursor.dir/vnd.mitch.user";
	/**
	 * Content type item
	 */
	public static final String CONTENT_TYPE_ITEM = "vnd.android.cursor.item/vnd.mitch.user";

		
	/**
	 * Name of the table in the database
	 */
	public static final String TABLE_NAME = "users";
	
	
	// DB COLUMNS
	/**
	 * Unique id for the User
	 */
	//public static final String _ID = "user_id";
	/**
	 * Users email, used like username
	 */
	public static final String EMAIL = "email";
	
	/**
	 * Users password 
	 */
	public static final String PASSWORD = "password";
	
	/**
	 * Institution the users belongs to
	 */
	public static final String INSTITUTION_ID = "institution_id";
	
	/**
	 * Country ID of the users origin 
	 */
	public static final String COUNTRY_ID = "country_id";
	
	/**
	 * First name of the user
	 */
	public static final String NAME = "name";
	
	/**
	 * Last name of the user
	 */
	public static final String SURNAME = "surname";
	
	/**
	 * Nickname of the user
	 */
	public static final String NICKNAME = "nickname";
	
	/**
	 * Gender of the user
	 */
	public static final String GENDER = "gender";
	
	/**
	 * Indicates if the user account is active
	 */
	public static final String ENABLED = "enabled";
	
	/**
	 * Phone number of the user
	 */
	public static final String PHONE_NUMBER = "phone_number";
	
	
	
	/* DATABASE COLUMNS INDEXES */
	
	public static final int INDEX_ID = 0;
	
	public static final int INDEX_REMOTE_ID = 1;
	
	public static final int INDEX_EMAIL = 2;
	
	public static final int INDEX_PASSWORD = 3;
	
	public static final int INDEX_INSTITUTION_ID = 4;
	
	public static final int INDEX_COUNTRY_ID = 5;
	
	public static final int INDEX_NAME = 6;
	
	public static final int INDEX_SURNAME = 7;
	
	public static final int INDEX_NICKNAME = 8;
	
	public static final int INDEX_GENDER = 9;
	
	public static final int INDEX_ENABLED = 10;
	
	public static final int INDEX_PHONE_NUMBER = 11;
	
	public static final int INDEX_STATE_FLAG = 12;	
	
	public static final String URI_TEMPLATE_STRING = "{user_id}";
	public static final String URI_TEMPLATE_STRING_EMAIL = "{email}";
	
	/* MAPPING KEYS */	
	private static final String M_KEY_START_TAG = "user";
	private static final String M_KEY_ID = "id";
	private static final String M_KEY_EMAIL = "email";
	private static final String M_KEY_PASSWORD = "password";
	private static final String M_KEY_INSTITUTION_ID = "institutionId";
	private static final String M_KEY_COUNTRY_ID = "countryId";
	private static final String M_KEY_NAME = "name";
	private static final String M_KEY_SURNAME = "surname";
	private static final String M_KEY_NICKNAME = "nickname";
	private static final String M_KEY_GENDER = "gender";
	private static final String M_KEY_ENABLED = "enabled";
	private static final String M_KEY_PHONE_NUMBER = "phoneNumber";
			
	public User() {
		mToDbMappings.put(M_KEY_START_TAG, START_TAG);
		mToDbMappings.put(M_KEY_ID, _ID);
		mToDbMappings.put(M_KEY_EMAIL, EMAIL);
		mToDbMappings.put(M_KEY_PASSWORD, PASSWORD);
		mToDbMappings.put(M_KEY_INSTITUTION_ID, INSTITUTION_ID);
		mToDbMappings.put(M_KEY_COUNTRY_ID, COUNTRY_ID);
		mToDbMappings.put(M_KEY_NAME, NAME);
		mToDbMappings.put(M_KEY_SURNAME, SURNAME);
		mToDbMappings.put(M_KEY_NICKNAME, NICKNAME);
		mToDbMappings.put(M_KEY_GENDER, GENDER);
		mToDbMappings.put(M_KEY_ENABLED, ENABLED);
		mToDbMappings.put(M_KEY_PHONE_NUMBER, PHONE_NUMBER);
	}	
}
